﻿#include<QApplication>
#include<QTranslator>
#include"XQPushServer.h"
#include"XQSslServer.h"
#include"XQMySql.hpp"
#include"XQMail.h"
#include"XQLog.hpp"
#include<QDebug>
#ifndef _DEBUG
#pragma comment(linker,"/subSystem:windows /entry:mainCRTStartup")
#endif // !_DEBUG

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    // 获取传递的参数列表
    QStringList args = QApplication::arguments();
    QApplication::setOrganizationName("xinyue");
    QApplication::setApplicationName("PushServer");
    QCoreApplication::setApplicationVersion("1.0.0");
   
    XQPushServer server;
    //server.userMysqlBridgingToAppMysql();
    //数据库设置
    auto mysql = server.userMysql();
    mysql->connection("PushMessage", "www.727370630.top", 3307, "PushMessage", "UCqFw(7lJ1_2kCaB", "PushMessage");
    //连接mysql的错误输出
    QObject::connect(mysql, &XQMySql::sqlError, [](const QString& error) {XQDebug << error; });
    //邮箱设置
    auto mail = server.mail();
    //邮箱账号名，如"****@126.com"
    mail->setUserName("727370630@qq.com");
    //邮箱密码:163邮箱为网易授权密码，不是邮箱账号对应的密码 类似DGJNQYDJXTULMGLS
    mail->setUserPwd("pjmvxtvfqhkibdhi");

    //发送邮箱地址，填你账号的地址,上面的邮箱账号名"****@163.com"，即填账号名
    mail->setSenderAddress("727370630@qq.com");
   
    using Debug = Http::Debug;
    server.setDebugModel(Debug::error | Debug::Run | Debug::Connection | Debug::Disconnect | Debug::HeadRequest);
    server.setName("PushMessage");
    auto tcp = server.tcp();
    tcp->setLocalCertificate("./certificate/www.727370630.top_public.crt");
    tcp->setPrivateKey("./certificate/www.727370630.top.key");
    tcp->setProtocol(Http::Protocol::https);
    //server.setServerName_local("127.0.0.1");
    server.setPort(6666);
    server.run();
    //开启线程池
    server.setThreadPool_run(true);
    ////mysql测试
    //XQAccountData account;




    return a.exec();
}
